package com.wujian.love.utils;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName: CommonInterceptorUtil
 * @description:数据同步工具类
 * @author: wujian
 * @Date: 2020-06-18 15:42
 **/
public class CommonInterceptorUtil {
    @Autowired
    private RedisUtil redisUtil;

    private static final Logger log = LoggerFactory.getLogger(CommonInterceptorUtil.class);

    /**
     * 恢复formToken,用于ajax防止重复提交,在controller中执行业务失败后调用
     */
    public void recoveryFormToken(String clinetToken) {
        if (StringUtils.isNotBlank(clinetToken)) {
            redisUtil.set("formToken_" + clinetToken, "1", 1000L, TimeUnit.MINUTES);
            log.warn("防重复提交业务失败_恢复成功formToken:" + clinetToken);
        }
    }
}
